package com.jacky.thread;

import java.util.HashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * Created by jacky on 2017/6/6 0006.
 */
public class Test {
    public static void main(String[] args) {
/*        HashMap<String, String> map = new HashMap<String, String>();
        map.put("songyao","lili");

        ExecutorService pool = Executors.newFixedThreadPool(5);
        MyTask task = new MyTask();
        Thread thread1 = new Thread(task);
        Thread thread2 = new Thread(task);
        Thread thread3 = new Thread(task);
        Thread thread4 = new Thread(task);
        Thread thread5 = new Thread(task);
        pool.submit(thread1);
        pool.submit(thread2);
        pool.submit(thread3);
        pool.submit(thread4);
        pool.submit(thread5);*/
        ThreadLocal<String> threadLocal = new ThreadLocal<>();
        threadLocal.set("你好");
        threadLocal.set("我好");
        threadLocal.set("他好");
        String s = threadLocal.get();
        System.out.println(s);
    }

}

class MyTask implements Runnable{
   private  int i = 0;
    @Override
    public void run() {
        while (i <100){
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + ":" + i++);
        }
    }
}
